import allure
from selenium.webdriver.common.by import By

from exercise2.page_frame.base_all import BaseAll


class SeniorPage(BaseAll):
    _CLICK_CLASSIFY = By.CSS_SELECTOR, "#search-in-category-header"
    _CLICK_QUESTION_AREA = By.CSS_SELECTOR, ".select-kit-collection>li:nth-child(1)"
    _CLICK_TOPIC = By.CSS_SELECTOR, '#search-status-options-header'
    _CLICK_OPENING = By.CSS_SELECTOR, '.select-kit-collection>li:nth-child(1)'
    _CLICK_SORT = By.CSS_SELECTOR, "#search-sort-by-header"
    _CLICK_SUPPORT = By.CSS_SELECTOR, ".select-kit-collection>li:nth-child(3)"
    _CLICK_SEARCH = By.CSS_SELECTOR, ".d-button-label"
    _INFORMATION = By.CSS_SELECTOR, '.blurb.container'

    @allure.step("按分类查找搜索信息")
    def senior_page(self):
        # 点击分类
        self.find_ele(*self._CLICK_CLASSIFY).click()
        # 点击提问区
        self.find_ele(*self._CLICK_QUESTION_AREA).click()
        # 点击话题
        self.find_ele(*self._CLICK_TOPIC).click()
        # 点击开放
        self.find_ele(*self._CLICK_OPENING).click()
        # 点击排序
        self.find_ele(*self._CLICK_SORT).click()
        # 点击赞最多
        self.find_ele(*self._CLICK_SUPPORT).click()
        # 点击搜索按钮
        self.find_ele(*self._CLICK_SEARCH).click()
        res = self.find_ele(*self._INFORMATION)
        return res
